package com.example.springboot.common;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

//在这里拦截
@Configuration
public class InterceptorConfig extends WebMvcConfigurationSupport {
    
    @Override
    protected void addInterceptors(InterceptorRegistry registry){
        
        registry.addInterceptor(jwtInterceptor())
                .addPathPatterns("/**")//配置jwt拦截规则
                .excludePathPatterns("/login");
        super.addInterceptors(registry);//拦截所有请求数据
        
    }

    @Bean
    public JwtInterceptor jwtInterceptor(){
        return new JwtInterceptor();
    }
}
